package cc.mrbird.monitoring.service.impl;

import cc.mrbird.assets.dao.AssetManaMapper;
import cc.mrbird.assets.domain.AssetMana;
import cc.mrbird.assets.domain.AssetType;
import cc.mrbird.common.service.impl.BaseService;
import cc.mrbird.monitoring.domain.Monitoring;
import cc.mrbird.monitoring.service.MonitoringService;
import org.apache.ibatis.type.YearTypeHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

@Service("monitoringService")
public class MonitoringServiceImpl extends BaseService<AssetMana> implements MonitoringService {
    private Logger log = LoggerFactory.getLogger(this.getClass());
    @Autowired
    private AssetManaMapper assetManaMapper;

    @Override
    public List<AssetType> findAllTypeAndId() {
        return assetManaMapper.findAllTypeAndId();
    }

    @Override
    public List<AssetType> findTotalType() {
        return assetManaMapper.findTotalType();
    }

    @Override
    public List<Integer> findNumerByType(String typeName) {
        Integer numer = assetManaMapper.findNumer(typeName);
        Integer numerNormal = assetManaMapper.findNumerNormal(typeName);
        Integer numerFault = assetManaMapper.findNumerFault(typeName);
        Integer numerUnconnected = assetManaMapper.findNumerUnconnected(typeName);
        Integer numerUnenabled = assetManaMapper.findNumerUnenabled(typeName);
        List<Integer> list = new ArrayList<>();
        list.add(numer);
        list.add(numerNormal);
        list.add(numerFault);
        list.add(numerUnconnected);
        list.add(numerUnenabled);
        return list;
    }


    @Override
    public List<AssetMana> findAllEquipment() {
        return assetManaMapper.findAllEquipment();
    }

    @Override
    public List<AssetMana> findAllNormal() {
        return assetManaMapper.findAllNormal();
    }

    @Override
    public List<AssetMana> findAllFault() {
        return assetManaMapper.findAllFault();
    }

    @Override
    public List<AssetMana> findAllUnconnected() {
        return assetManaMapper.findAllUnconnected();
    }

    @Override
    public List<AssetMana> findAllUnenabled() {
        return assetManaMapper.findAllUnenabled();
    }

    @Override
    public List<AssetMana> fingAllByIds(String ids) {
        List<AssetMana> list = new ArrayList<>();
        List<String> list1 = Arrays.asList(ids.split(","));
        for (String s : list1) {
            AssetMana assetMana = assetManaMapper.findById(Long.parseLong(s));
            list.add(assetMana);
        }
        return list;
    }

    @Override
    public List<AssetMana> findAllAssetByTypeAndStatus(String asset_type, Integer equipment_satus) {

        List<AssetMana> assetManaList =  assetManaMapper.findAllAssetByTypeAndStatus(asset_type,equipment_satus);
        return  assetManaList;
    }
}
